<%--
  Created by IntelliJ IDEA.
  User: lee
  Date: 16-10-24
  Time: 下午11:38
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html ng-app="borrowModule">
<head>
    <title>借书-还书</title>
    <script src="<%=request.getContextPath()%>/js/angular-1.0.8/angular.js"></script>
    <script src="<%=request.getContextPath()%>/js/angular-1.0.8/angular-route.min.js"></script>
    <script type="text/javascript">
        var borrowModule=angular.module("borrowModule",[]);
        borrowModule.controller("BorrowController",function($scope, $http) {

            $scope.borbookshow=false;
            $scope.retbookshow=false;
            $scope.borCardId='200001';
            $scope.borIdsn='9787121215742';
            $scope.retIdsn='9787121215742';

            $scope.openRetBook = function () {
                $scope.retbookshow=true;
                $scope.borbookshow= false;
            };

            $scope.closeborbook = function () {
                $scope.borbookshow=false;
            };

            $scope.closeretbook = function () {
                $scope.retbookshow=false;
            };
            $scope.openBorBook=function() {
                $scope.borbookshow= !$scope.borbookshow;
               $scope.retbookshow=false;
            };
            /**/
            $scope.doBorBook=function(){

                $http({
                    url:"<%=request.getContextPath()%>/book/borrow.do",
                    params:{"cardId":$scope.borCardId,"idsn":$scope.borIdsn},
                    method:"post"
                }).success(function(data){
                    alert("借书："+data)  ;
                    $scope.closeborbook();


                })
            };
            $scope.doRetBook=function(){
                alert("还书成功");
                $scope.closeretbook();
            }

        });

    </script>

</head>
<body ng-controller="BorrowController">

<div >
    <button id="btnBorBook" ng-click="openBorBook()">借书</button>
    <button id="btnRetBook" ng-click="openRetBook()">还书</button>

    <%--借书--%>
    <div id="dd-borbook" ng-show="borbookshow">
        <h2>借书</h2>
        <label for="cardId">读者图书证编号</label>
        <input type="text" name="cardId" id="cardId" ng-model="borCardId"/> <br>
        <label for="cardId">馆藏图书条形码</label>
        <input type="text" name="borbook-idsn" id="borbook-idsn" ng-model="borIdsn"/> <br>

        <button id="btn-borbook-submit" ng-click="doBorBook()">确定</button>
        <button id="btn-borbook-cancel" ng-click="closeborbook()">取消</button>
    </div>
    <%--还书--%>
    <div id="dd-retbook" ng-show="retbookshow">
        <h2>还书</h2>
        <label for="cardId">馆藏图书条形码</label>
        <input type="text" name="retbook-idsn" id="retbook-idsn" ng-model="retIdsn"/> <br>
        <button id="btn-retbook-submit" ng-click="doRetBook()">确定</button>
        <button id="btn-retbook-cancel" ng-click="closeretbook()">取消</button>
    </div>
</div>
</body>
</html>
